<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('系统通知列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>状态：</label>
                                <select name="euNote">
                                    <option value="">全部</option>
                                    <option value="0">待通知</option>
                                    <option value="1">已发送</option>
                                    <option value="2">已作废</option>
                                </select>
                            </li>
                            <li>
                                <label>接收人：</label>
                                <input type="text" name="naEmp"/>
                            </li>
                            <li>
                                <label>开始时间：</label>
                                <input type="text" class="time-input" placeholder="开始时间" name="dayBegin" th:value="${dayBegin}"/>~
                                <input type="text" class="time-input" placeholder="结束时间" name="dayEnd" th:value="${dayEnd}"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                                <a class="btn btn-danger btn-rounded btn-sm" onclick="cancelNote()"><i class="fa fa-remove"></i>&nbsp;作废</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('base:note:edit')}]];
        var removeFlag = [[${@permission.hasPermi('base:note:remove')}]];
        var prefix = ctx + "base/note";
        function cancelNote() {
            $.ajax({
                url: prefix + "/cancel",
                type: 'GET',
                success: function (res) {
                    if (res.code == "0") {
                        $.modal.alertSuccess("已作废"+res.data+"条");
                    } else {
                        $.modal.alertError(res.msg);
                    }
                }
            });
        }
        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "系统通知",
                rowStyle:function (row,index) {
                    if(row.euNote==2) {
                        return {css:{"color":'grey'}}
                    }
                    return '';
                },
                columns: [{
                    checkbox: true
                },
                {
                    field: 'idNote',
                    title: '主键',
                    visible: false
                },
                {
                    field: 'naEmp',
                    title: '接收人'
                },
                {
                    field: 'tel',
                    title: '电话'
                },
                {
                    field: 'dtNoteExpect',
                    title: '预计发送时间'
                },
                {
                    field: 'euNote',
                    title: '发送状态',
                    formatter: function(value, row, index) {
                        if(row.euNote==0) {
                            return "待通知";
                        } if(row.euNote==1) {
                            return "已通知";
                        } if(row.euNote==2) {
                            return "已作废";
                        }
                    }
                },
                {
                    field: 'naEmpCre',
                    title: '创建人'
                },
                {
                    field: 'dtSysCre',
                    title: '创建时间'
                },
                {
                    field: 'des',
                    title: '内容',
                    width:400
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        if(row.euNote==0) {
                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.idNote + '\')"><i class="fa fa-remove"></i>删除</a>');
                        }
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
    </script>
</body>
</html>